<?php

namespace App\Common\WX;


use XWX\Common\H;

class WxWord
{
    private $word;
    private $app;
    private $key;
    private $suffix;

    public function __construct($string1)
    {
        $this->word = $string1;
        if (H::funcStrHasAnyText($string1))
        {
            preg_match('/^([A-Za-z_]+)([0-9\-]*)([#]*)(.*)/', $string1, $matches);

            if (count($matches) > 0)
            {
                $this->app = $matches[1];
                $this->key = $matches[2];
                $this->suffix = $matches[4];
            }
        }
    }


    function content()
    {
        return $this->word;
    }

    function app()
    {
        return $this->app;
    }

    function key()
    {
        return $this->key;
    }

    function keyNum()
    {
        return H::funcStrIsNullOrEmpty($this->key) ? 0 : $this->key;
    }

    function suffix()
    {
        return $this->suffix;
    }
}